<?php include "conn.php";?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>精选优品-产品列表-<?php echo $SiteTitle;?></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> -->
    <meta name="keywords" content="精选优品-产品列表-<?php echo $SiteKeywords;?> ">
    <meta name="description" content="精选优品-产品列表-<?php echo $SiteDescription;?> " />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <?php include "public/cssjs.php";?>
</head>
<body>
<?php include "public/top.php";?>
<section id="swiper1" class="swiper">
    <div class="swiper-container ">
        <div class="swiper-wrapper">
            <?php
            $connt = new Mysql();
            $rs = $connt->getRow("select * from lunbo");
            if($rs["a1_img"]!=""){ echo '<div class="swiper-slide"><img src="pic/'.$rs["a1_img"].'" alt="" class="img-fluid"></div>';}
            if($rs["a2_img"]!=""){ echo '<div class="swiper-slide"><img src="pic/'.$rs["a2_img"].'" alt="" class="img-fluid"></div>';}
            if($rs["a3_img"]!=""){ echo '<div class="swiper-slide"><img src="pic/'.$rs["a3_img"].'" alt="" class="img-fluid"></div>';}
            if($rs["a4_img"]!=""){ echo '<div class="swiper-slide"><img src="pic/'.$rs["a4_img"].'" alt="" class="img-fluid"></div>';}
            if($rs["a5_img"]!=""){ echo '<div class="swiper-slide"><img src="pic/'.$rs["a5_img"].'" alt="" class="img-fluid"></div>';}
            ?>
        </div>
        <!-- 如果需要分页器 -->
        <div class="swiper-pagination"></div>
        <!-- 如果需要滚动条 -->
    </div>
</section>
<?php

$conn=new Mysql();
$sql = "select * from products where is_hot=1 order by adate desc";
$page_size = 8;					 //定义每页显示多少记录
$num_cnt = mysqli_num_rows($conn->query($sql)); //获取总记录数
$page_cnt = ceil($num_cnt/$page_size);  //计算总页数
if(isset($_GET["page"])){
    $page = intval($_GET["page"]);
}else{
    $page = 1;
}
if ($page<1)
{
    $page=1;
}
elseif ($page>$page_cnt)
{
    $page=$page_cnt;
}
$query_start = ($page - 1 ) * $page_size;   //计算每页开始的记录号
$query_sql = $sql." limit $query_start,$page_size"; //使用limit获取记录
?>

<!--  -->
<!--  -->
<div class="home-m home-someProducts">
    <div class="container">
        <div class="home-heading">
            <div class="home-title"><span>精选优品</span></div>
        </div>
        <div class="home-body">
            <div class="row">
                <?php

                if($num_cnt>0) {
                    $i = 1;
                    $row = $conn->getAll($query_sql);
                    foreach ($row as $key => $rsp) {

                        ?>
                        <div class=" col-md-6 col-xl-3 mb-4">
                            <div class="home-someProducts-item">
                                <div class="label"><strong><?php echo $rsp["objects"];?></strong></div>
                                <div class="home-someProducts-img"><a href="detail.php?id=<?php echo $rsp["id"];?>"><img class="hvr-grow" src="/pic/<?php echo $rsp["pic"];?>" alt="<?php echo $rsp["title"];?>"></a>
                                    <div class="home-someProducts-action"><a href="cart.php?id=">加入购物车 <i class="iconfont icon-gouwuche"></i></a></div>
                                </div>

                                <div class="home-someProducts-caption">
                                    <div class="home-someProducts-title"><?php echo $rsp["title"];?></div>
                                    <div class="home-someProducts-rating"><?php echo $rsp["styles"];?></div>
                                    <div class="home-someProducts-price"><small>¥<?php echo $rsp["ys_s_price"];?></small>¥<?php echo $rsp["ys_e_price"];?></div>
                                </div>
                            </div>
                        </div>

                        <?php
                    }
                }
                ?>

            </div>
        </div>
        <div class="page">
            <nav aria-label="Page navigation example">
                <?php Pagefenye($num_cnt,$page_cnt,$page);?>
            </nav>
        </div>
    </div>
</div>
<!--  -->



<?php include "public/footer.php";?>
<?php include "public/bottom.php";?>
</body>
</html>